package modelo.bean;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.xml.bind.annotation.XmlRootElement;

import org.codehaus.jackson.annotate.JsonManagedReference;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@XmlRootElement
@Entity
@PrimaryKeyJoinColumn(name = "idAluno")
public class Aluno extends Usuario implements Serializable {

	public Aluno() {

	}

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private String semestre;
	
	@ManyToMany(cascade = CascadeType.ALL)
	@JoinTable(joinColumns = { @JoinColumn(name = "prova_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "aluno_id", nullable = false, updatable = false) })
	@Fetch(FetchMode.JOIN)
	private List<Prova> listaDeProvas;

	public String getSemestre() {
		return semestre;
	}

	public void setSemestre(String semestre) {
		this.semestre = semestre;
	}

	@JsonManagedReference("aluno-prova")
	public List<Prova> getListaDeProvas() {
		return listaDeProvas;
	}

	public void setListaDeProvas(List<Prova> listaDeProvas) {
		this.listaDeProvas = listaDeProvas;
	}

}
